package com.net.wanjian.networkhospitalmanager.activity.skilltrain;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.baoyz.actionsheet.ActionSheet;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.ms.square.android.expandabletextview.ExpandableTextView;
import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.activity.ScanPortraitActivity;
import com.net.wanjian.networkhospitalmanager.activity.base.BaseActivity;
import com.net.wanjian.networkhospitalmanager.bean.EnterLabResult;
import com.net.wanjian.networkhospitalmanager.bean.LabReserveDetailResult;
import com.net.wanjian.networkhospitalmanager.bean.LabReserveListReturn;
import com.net.wanjian.networkhospitalmanager.bean.StudentApplyReserveReturn;
import com.net.wanjian.networkhospitalmanager.bean.StudentLabReserveListResult;
import com.net.wanjian.networkhospitalmanager.consts.ErrorCodeReturn;
import com.net.wanjian.networkhospitalmanager.consts.LabReserveBtnConst;
import com.net.wanjian.networkhospitalmanager.net.HttpUtil;
import com.net.wanjian.networkhospitalmanager.netstatus.NetUtils;
import com.net.wanjian.networkhospitalmanager.utils.ProgressDialogUtils;
import com.net.wanjian.networkhospitalmanager.utils.SharedXmlUtil;
import com.net.wanjian.networkhospitalmanager.utils.TimeDateUtils;
import com.net.wanjian.networkhospitalmanager.utils.ToastUtil;
import com.net.wanjian.networkhospitalmanager.utils.URLDecoderUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import io.reactivex.observers.DisposableObserver;
import me.gujun.android.taggroup.TagGroup;

/**
 * 此activity专为学生历史预约详情服务，和预约详情页面公用一个布局
 */
public class StudentHistoryLabDetailsActivity extends BaseActivity implements View.OnClickListener {
    public static final String LAB_RESERVE_ID_KEY = "com.net.wanjian.activity.labdetailsactivity.lab_reserve_id_key";
    public static final String LAB_RESERVE_DATA_KEY = "com.net.wanjian.activity.labdetailsactivity.lab_reserve_data_key";
    public static final String LAB_RESERVE_TYPE_KEY = "com.net.wanjian.activity.labdetailsactivity.lab_reserve_key"; // 0为实验室，1为我的预约,2为老师

    @BindView(R.id.top_back_layout)
    LinearLayout topBackLayout;
    @BindView(R.id.top_title_tv)
    TextView topTitleTv;
    @BindView(R.id.lab_details_taggroup)
    TagGroup labDetailsTaggroup;
    @BindView(R.id.expand_text_view)
    ExpandableTextView mExpandableTextView;
    @BindView(R.id.lab_details_enter_btn)
    Button labReserveBtn;
    @BindView(R.id.lab_details_name_tv)
    TextView labDetailsNameTv;
    @BindView(R.id.lab_details_room_tv)
    TextView labDetailsRoomTv;
    @BindView(R.id.lab_details_teacher_tv)
    TextView labDetailsTeacherTv;
    @BindView(R.id.lab_details_open_time_tv)
    TextView labDetailsOpenTimeTv;
    @BindView(R.id.lab_details_person_num_tv)
    TextView labDetailsPersonNumTv;
    @BindView(R.id.expandable_text)
    TextView expandableText;
    @BindView(R.id.expand_collapse)
    ImageButton expandCollapse;

    private String labName;
    private int btnType;
    private String labReserveId;
    private LabReserveListReturn.DataBean.LabReserveListBean labReserve;
    private StudentLabReserveListResult.DataBean.CurrentLabReserveListBean d;

    private LocalBroadcastManager localBroadcastManager;
    private String memberId;

    @Override
    protected void initData() {
        localBroadcastManager = LocalBroadcastManager.getInstance(this);

        topTitleTv.setText("详情");
        topBackLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StudentHistoryLabDetailsActivity.this.finish();
            }
        });

        int labType = -1;
        //得到传递过过来的值，实验室id和按钮的状态
        Bundle bundle = getIntent().getExtras();
        if (null != bundle){
            memberId = bundle.getString(StudentHistoryLaboratoryListActivity.LAB_RESERVE_MEMBER_ID_KEY);
            labReserveId = bundle.getString(StudentHistoryLabDetailsActivity.LAB_RESERVE_ID_KEY);
            //获取实验室预约和我的预约或老师相关
            labType = bundle.getInt(StudentHistoryLabDetailsActivity.LAB_RESERVE_TYPE_KEY);
        }else {
            return;
        }


        getLabDetailHttpRequest(labReserveId);


        //老师不能进入实验室
        if (SharedXmlUtil.getInstance().getUserIdentity().equals("1")) {
            //这里通过22 区别老师2的标记，在详情页面判断是否显示回执按钮
            if (labType == 22) {
                setLabReserveBtn(LabReserveBtnConst.RECEIPT);
                d = (StudentLabReserveListResult.DataBean.CurrentLabReserveListBean) bundle.getSerializable(StudentHistoryLabDetailsActivity.LAB_RESERVE_DATA_KEY);
            }else {
                setLabReserveBtn(LabReserveBtnConst.NO_RESERVED);
            }

            if (labType == 2) {
                d = (StudentLabReserveListResult.DataBean.CurrentLabReserveListBean) bundle.getSerializable(StudentHistoryLabDetailsActivity.LAB_RESERVE_DATA_KEY);
            }
        } else {
            //实验室预约
            if (labType == 0) {
                labReserve = (LabReserveListReturn.DataBean.LabReserveListBean) bundle.getSerializable(StudentHistoryLabDetailsActivity.LAB_RESERVE_DATA_KEY);
                //获取当前人数和最大人数
                String currentPNum = URLDecoderUtil.getDecoder(labReserve.getLabReserveCurrentPerson());
                String maxPNum = URLDecoderUtil.getDecoder(labReserve.getLabReserveMaxPerson());
                //人数小于总人数允许预约，否则不允许
                if (Integer.parseInt(currentPNum) < Integer.parseInt(maxPNum)) {
                    setLabReserveBtn(LabReserveBtnConst.CAN_RESERVED);
                } else {
                    setLabReserveBtn(LabReserveBtnConst.UNABLE_RESERVED);
                }
            } else {
                if (labType == 1) {
                    //我的预约
                    //获取item的所有数据对象
                    d = (StudentLabReserveListResult.DataBean.CurrentLabReserveListBean) bundle.getSerializable(StudentHistoryLabDetailsActivity.LAB_RESERVE_DATA_KEY);

                    //学生预约按钮的状态
                    //服务器已经取消
                    if (d.getLabReserveStatus().equals("2")) {
                        setLabReserveBtn(LabReserveBtnConst.SERVER_CANCEL);
                    } else {
                        //未到截止时间，取消预约
                        if (TimeDateUtils.isStopTime(URLDecoderUtil.getDecoder(d.getLabReserveEndTime()))) {
                            //过了截止时间，判断是否开放那天（这里只要过了0点，就可以进入实验室）
                            if (TimeDateUtils.isOpenTime(URLDecoderUtil.getDecoder(d.getLabReserveOpenTime()))) {
                                setLabReserveBtn(LabReserveBtnConst.ENTER_LAB);
                            } else {
                                setLabReserveBtn(LabReserveBtnConst.WAIT_OPEN);
                            }
                        } else {

                            setLabReserveBtn(LabReserveBtnConst.CANCEL_RESERVED);
                        }

                    }
                }else if (labType == 33){
                    setLabReserveBtn(LabReserveBtnConst.LOOK_HISTORY_RESERVE);
//                    studentHistoryReserve = (StudentHistoryLabReserveResult.DataBean.PastLabReserveListBean) bundle.getSerializable(LabDetailsActivity.LAB_RESERVE_DATA_KEY);
                }

            }

        }


        labReserveBtn.setOnClickListener(this);
    }

    /**
     * 进入实验室权限验证
     *
     * @param labReserveId
     */
    private void enterLabHttpRequest(final String labReserveId) {
        HttpUtil.enterLab(SharedXmlUtil.getInstance().getDeviceId(), SharedXmlUtil.getInstance().getToken(),
                SharedXmlUtil.getInstance().getHospitalId(), SharedXmlUtil.getInstance().getUserIdentityId(), labReserveId, new DisposableObserver<EnterLabResult>() {
                    @Override
                    public void onNext(EnterLabResult enterLabResult) {
                        if (enterLabResult.getResult().equals(ErrorCodeReturn.success + "")) {
                            SharedXmlUtil.getInstance().setToken(URLDecoderUtil.getDecoder(enterLabResult.getData().getToken()));
                            Bundle bundle = new Bundle();
                            bundle.putString(StudentHistoryLaboratoryListActivity.LAB_RESERVE_MEMBER_ID_KEY, URLDecoderUtil.getDecoder(enterLabResult.getData().getLabReserveMember().getLabReserveMemberID()));
                            bundle.putString(StudentHistoryLaboratoryListActivity.LAB_RESERVE_NAME_KEY, labName);
                            bundle.putString(StudentHistoryLaboratoryListActivity.LAB_RESERVE_ID_KEY,labReserveId);
                            openActivity(StudentHistoryLaboratoryListActivity.class, bundle);

                            closeCurrentActivity();

                        } else {
                            ToastUtil.showToast("请签到后进入实验室");
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    /**
     * 获取详情
     *
     * @param labReserveId
     */
    private void getLabDetailHttpRequest(final String labReserveId) {
        ProgressDialogUtils.showProgressDialog(this, null, R.string.loading_text);
        HttpUtil.labReserveDetail(SharedXmlUtil.getInstance().getDeviceId(), SharedXmlUtil.getInstance().getToken(),
                SharedXmlUtil.getInstance().getHospitalId(), labReserveId, new DisposableObserver<LabReserveDetailResult>() {
                    @SuppressLint("SetTextI18n")
                    @Override
                    public void onNext(LabReserveDetailResult labReserveDetailResult) {
                        if (labReserveDetailResult.getResult().equals(ErrorCodeReturn.success + "")) {
                            SharedXmlUtil.getInstance().setToken(labReserveDetailResult.getData().getToken());

                            LabReserveDetailResult.DataBean.LabReserveInfoBean info = labReserveDetailResult.getData().getLabReserveInfo();
                            labName = URLDecoderUtil.getDecoder(info.getLabReserveName());
                            labDetailsNameTv.setText(URLDecoderUtil.getDecoder(info.getLabReserveName()));

                            StringBuilder builder = new StringBuilder();
                            for (int i = 0; i < info.getRoomList().size(); i++) {
                                if (i == info.getRoomList().size() - 1) {
                                    builder.append(URLDecoderUtil.getDecoder(info.getRoomList().get(i).getRoomName()));
                                } else {
                                    builder.append(URLDecoderUtil.getDecoder(info.getRoomList().get(i).getRoomName()) + "、");
                                }
                            }

                            labDetailsRoomTv.setText("房间：" + builder.toString());
                            labDetailsTeacherTv.setText("指导老师：" + URLDecoderUtil.getDecoder(info.getGuideTeacherNameArray()));
//                            labDetailsOpenTimeTv.setText("开放时间：" + TimeDateUtils.formatTimeFriend(URLDecoderUtil.getDecoder(info.getLabReserveOpenTime())));
                            labDetailsPersonNumTv.setText("预约人数：" + URLDecoderUtil.getDecoder(info.getLabReserveCurrentPerson()) + "/" + URLDecoderUtil.getDecoder(info.getLabReserveMaxPerson()));
                            mExpandableTextView.setText("描述：" + URLDecoderUtil.getDecoder(info.getLabReserveRemark()));

                            //设置开放到关闭的时间，需要格式化
                            String openTime = TimeDateUtils.formatTimeFriend(URLDecoderUtil.getDecoder(info.getLabReserveOpenTime()));
                            String closeTime = TimeDateUtils.formatTimeFriend(URLDecoderUtil.getDecoder(info.getLabReserveCloseTime()));
                            String ot = openTime.split(" ")[0];
                            String ct = closeTime.split(" ")[0];
                            if (ot.equals(ct)) {
                                labDetailsOpenTimeTv.setText("开放时间：" +openTime + "—" + closeTime.split(" ")[1]);
                            } else {
                                labDetailsOpenTimeTv.setText("开放时间：" +openTime + "—" + closeTime);
                            }


                            //技能练习，只取出第一个房间的
                            List<String> skillTrain = new ArrayList<>();
                            for (int i = 0; i < info.getRoomList().get(0).getTrainTypeList().size(); i++) {
                                skillTrain.add(URLDecoderUtil.getDecoder(info.getRoomList().get(0).getTrainTypeList().get(i).getTrainTypeName()));
                            }

                            labDetailsTaggroup.setTags(skillTrain);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        ProgressDialogUtils.dismissProgressDialog();
                    }

                    @Override
                    public void onComplete() {
                        ProgressDialogUtils.dismissProgressDialog();
                    }
                });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_lab_details;
    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    private void closeCurrentActivity() {
        finish();
    }

    private void studentApplyReserve() {
        HttpUtil.studentApplyReserve(SharedXmlUtil.getInstance().getDeviceId(), SharedXmlUtil.getInstance().getToken(),
                SharedXmlUtil.getInstance().getHospitalId(), SharedXmlUtil.getInstance().getUserIdentityId(), labReserve.getLabReserveID(), new DisposableObserver<StudentApplyReserveReturn>() {
                    @Override
                    public void onNext(StudentApplyReserveReturn studentApplyReserveReturn) {
                        if (studentApplyReserveReturn.getResult().equals("1")) {
                            ToastUtil.showToast("预约成功，请到我的预约中进行查看");

                            refreshMyAndLab();
                            closeCurrentActivity();

                        } else {
                            switch (Integer.parseInt(studentApplyReserveReturn.getResult())) {
                                case ErrorCodeReturn.personLimit:
                                    ToastUtil.showToast("预约人数已达上限");
                                    break;
                                case ErrorCodeReturn.excessStopTime:
                                    ToastUtil.showToast("已经过了预约截止时间");
                                    break;
                                case ErrorCodeReturn.orderCancel:
                                    ToastUtil.showToast("实验预约已经取消");
                                    break;
                                case ErrorCodeReturn.userIsBlackList:
                                    ToastUtil.showToast("您已经被加入黑名单，无法预约");
                                    break;
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }


    private void cancelReserve() {
        //取消预约
        HttpUtil.studentCancelReserve(SharedXmlUtil.getInstance().getDeviceId(), SharedXmlUtil.getInstance().getToken(),
                SharedXmlUtil.getInstance().getHospitalId(), SharedXmlUtil.getInstance().getUserIdentityId(), d.getLabReserveID(), new DisposableObserver<StudentApplyReserveReturn>() {
                    @Override
                    public void onNext(StudentApplyReserveReturn studentApplyReserveReturn) {
                        if (studentApplyReserveReturn.getResult().equals("1")) {
                            ToastUtil.showToast("成功取消预约");
                            refreshMyAndLab();
                            closeCurrentActivity();
                        } else {
                            ToastUtil.showToast("无法取消预约");
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    //回执弹出dialog
    public void teacherReceipt() {
        ActionSheet.createBuilder(this, getSupportFragmentManager())
                .setCancelButtonTitle("取消")
                .setOtherButtonTitles("参加", "不参加", "更换老师")
                .setCancelableOnTouchOutside(true)
                .setListener(new ActionSheet.ActionSheetListener() {
                    @Override
                    public void onDismiss(ActionSheet actionSheet, boolean b) {

                    }

                    @Override
                    public void onOtherButtonClick(ActionSheet actionSheet, int i) {
                        switch (i) {
                            case 0:
                                ProgressDialogUtils.showProgressDialog(StudentHistoryLabDetailsActivity.this, null, R.string.loading_text);
                                HttpUtil.teacherReplyLabReserve(SharedXmlUtil.getInstance().getDeviceId(), SharedXmlUtil.getInstance().getToken(),
                                        SharedXmlUtil.getInstance().getHospitalId(), SharedXmlUtil.getInstance().getUserIdentityId(), d.getLabReserveID(),
                                        "1", new DisposableObserver<StudentApplyReserveReturn>() {
                                            @Override
                                            public void onNext(StudentApplyReserveReturn studentApplyReserveReturn) {
                                                if (studentApplyReserveReturn.getResult().equals(ErrorCodeReturn.success + "")) {
                                                    ToastUtil.showToast("参加成功");
                                                    closeCurrentActivity();
                                                }
                                            }

                                            @Override
                                            public void onError(Throwable e) {
                                                ProgressDialogUtils.dismissProgressDialog();
                                            }

                                            @Override
                                            public void onComplete() {
                                                ProgressDialogUtils.dismissProgressDialog();
                                            }
                                        });
                                break;
                            case 1:
                                ProgressDialogUtils.showProgressDialog(StudentHistoryLabDetailsActivity.this, null, R.string.loading_text);
                                HttpUtil.teacherReplyLabReserve(SharedXmlUtil.getInstance().getDeviceId(), SharedXmlUtil.getInstance().getToken(),
                                        SharedXmlUtil.getInstance().getHospitalId(), SharedXmlUtil.getInstance().getUserIdentityId(), d.getLabReserveID(),
                                        "2", new DisposableObserver<StudentApplyReserveReturn>() {
                                            @Override
                                            public void onNext(StudentApplyReserveReturn studentApplyReserveReturn) {
                                                if (studentApplyReserveReturn.getResult().equals(ErrorCodeReturn.success + "")) {
                                                    ToastUtil.showToast("取消参加成功");
                                                    closeCurrentActivity();
                                                }
                                            }

                                            @Override
                                            public void onError(Throwable e) {
                                                ProgressDialogUtils.dismissProgressDialog();
                                            }

                                            @Override
                                            public void onComplete() {
                                                ProgressDialogUtils.dismissProgressDialog();
                                            }
                                        });
                                break;
                            case 2:
                                scanQRcode();
                                break;
                        }

                    }
                }).show();
    }

    /**
     * adapter中调用扫描二维码
     */
    public void scanQRcode() {
        IntentIntegrator integrator = new IntentIntegrator(this);
        integrator.setPrompt("请扫描教师的二维码");
        integrator.setCaptureActivity(ScanPortraitActivity.class);
        integrator.initiateScan();

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        final IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
        if (result != null) {
            if (result.getContents() == null) {
//                Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
            } else {
                //更新teacherfragment的adapter数据
                if (d.getLabReserveID() != null) {
                    HttpUtil.replaceGuidTeacher(SharedXmlUtil.getInstance().getDeviceId(), SharedXmlUtil.getInstance().getToken(),
                            SharedXmlUtil.getInstance().getHospitalId(), SharedXmlUtil.getInstance().getUserIdentityId(), d.getLabReserveID(), result.getContents().split("\\^")[2], new DisposableObserver<StudentApplyReserveReturn>() {
                                @Override
                                public void onNext(StudentApplyReserveReturn studentApplyReserveReturn) {
                                    if (studentApplyReserveReturn.getResult().equals(ErrorCodeReturn.replaceTeacherAlreadyexist + "")){
                                        ToastUtil.showToast("更换的老师已经存在该实验室预约中");
                                        return;
                                    }

                                    if (studentApplyReserveReturn.getResult().equals(ErrorCodeReturn.success + "")) {
                                        closeCurrentActivity();
                                    }
                                }

                                @Override
                                public void onError(Throwable e) {

                                }

                                @Override
                                public void onComplete() {

                                }
                            });
                }
            }
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

    @Override
    public void onClick(View v) {
        Log.e(TAG, "onClick: "+btnType);
        switch (btnType) {
            case LabReserveBtnConst.NO_RESERVED:

                break;
            case LabReserveBtnConst.UNABLE_RESERVED:

                break;
            case LabReserveBtnConst.CAN_RESERVED://立即预约
                studentApplyReserve();
                break;
            case LabReserveBtnConst.CANCEL_RESERVED: //取消预约
                cancelReserve();
                break;
            case LabReserveBtnConst.WAIT_OPEN:

                break;
            case LabReserveBtnConst.ENTER_LAB: //进入实验室
//                enterLabHttpRequest(labReserveId);
                Bundle bundle = new Bundle();
                bundle.putString(StudentHistoryLaboratoryListActivity.LAB_RESERVE_MEMBER_ID_KEY, memberId);
                bundle.putString(StudentHistoryLaboratoryListActivity.LAB_RESERVE_NAME_KEY, labName);
                bundle.putString(StudentHistoryLaboratoryListActivity.LAB_RESERVE_ID_KEY,labReserveId);
                openActivity(StudentHistoryLaboratoryListActivity.class, bundle);

                closeCurrentActivity();
                break;
            case LabReserveBtnConst.SERVER_CANCEL:

                break;
            case LabReserveBtnConst.RECEIPT://老师回执
                teacherReceipt();
                break;
        }
    }

    public void setLabReserveBtn(int type) {
        switch (type) {
            case LabReserveBtnConst.NO_RESERVED:
                labReserveBtn.setVisibility(View.GONE);
                btnType = LabReserveBtnConst.NO_RESERVED;
                break;
            case LabReserveBtnConst.UNABLE_RESERVED:
                labReserveBtn.setEnabled(false);
                labReserveBtn.setText("立即预约");
                labReserveBtn.setBackgroundResource(R.drawable.lab_reserve_btn_color);
                btnType = LabReserveBtnConst.UNABLE_RESERVED;
                break;
            case LabReserveBtnConst.CAN_RESERVED:
                labReserveBtn.setEnabled(true);
                labReserveBtn.setText("立即预约");
                labReserveBtn.setBackgroundResource(R.drawable.my_reserve_btn_color);
                btnType = LabReserveBtnConst.CAN_RESERVED;
                break;
            case LabReserveBtnConst.CANCEL_RESERVED:
                labReserveBtn.setEnabled(true);
                labReserveBtn.setText("取消预约");
                labReserveBtn.setBackgroundResource(R.drawable.btn_bg_cancel);
                btnType = LabReserveBtnConst.CANCEL_RESERVED;
                break;
            case LabReserveBtnConst.WAIT_OPEN:
                labReserveBtn.setEnabled(false);
                labReserveBtn.setText("等待开放");
                labReserveBtn.setBackgroundResource(R.drawable.lab_reserve_btn_color);
                btnType = LabReserveBtnConst.WAIT_OPEN;
                break;
            case LabReserveBtnConst.ENTER_LAB:
                labReserveBtn.setEnabled(true);
                labReserveBtn.setText("进入实验室");
                labReserveBtn.setBackgroundResource(R.drawable.my_reserve_btn_color);
                btnType = LabReserveBtnConst.ENTER_LAB;
                break;
            case LabReserveBtnConst.SERVER_CANCEL:
                labReserveBtn.setEnabled(false);
                labReserveBtn.setText("服务器已取消");
                labReserveBtn.setBackgroundResource(R.drawable.my_reserve_btn_color);
                btnType = LabReserveBtnConst.SERVER_CANCEL;
                break;
            case LabReserveBtnConst.RECEIPT:
                labReserveBtn.setEnabled(true);
                labReserveBtn.setText("回执");
                labReserveBtn.setBackgroundResource(R.drawable.my_reserve_btn_color);
                btnType = LabReserveBtnConst.RECEIPT;
                break;
            case LabReserveBtnConst.LOOK_HISTORY_RESERVE:
                labReserveBtn.setEnabled(true);
                labReserveBtn.setText("查  看");
                labReserveBtn.setBackgroundResource(R.drawable.my_reserve_btn_color);
                btnType = LabReserveBtnConst.ENTER_LAB;
                break;
        }
    }

    /**
     * 刷新实验室和我的预约
     */
    private void refreshMyAndLab(){
        Intent intent = new Intent();
        intent.setAction("refreshmyreservation");
        localBroadcastManager.sendBroadcast(intent);

        Intent intent1 = new Intent();
        intent1.setAction("refreshlabreserve");
        localBroadcastManager.sendBroadcast(intent1);
    }

}
